package ferran.tomas.dominio;

import java.lang.reflect.Field;

public class Producto {
	private String id;
	private String precio;
	private String rating;
	private String cantidad;
	
	
	
	public Producto(String id, String precio, String rating, String cantidad) {
		this.id = id;
		this.setPrecio(precio);
		this.setRating(rating);
		this.setCantidad(cantidad);
		
	}
	
	public String getId() {
		return id;
	}

	
	@Override public String toString() {
	    StringBuilder result = new StringBuilder();
	    String newLine = System.getProperty("line.separator");

	    result.append( this.getClass().getName() );
	    result.append( " Object {" );
	    result.append(newLine);

	    //determine fields declared in this class only (no fields of superclass)
	    Field[] fields = this.getClass().getDeclaredFields();

	    //print field names paired with their values
	    for ( Field field : fields  ) {
	      result.append("  ");
	      try {
	        result.append( field.getName() );
	        result.append(": ");
	        //requires access to private field:
	        result.append( field.get(this) );
	      }
	      catch ( IllegalAccessException ex ) {
	        System.out.println(ex);
	      }
	      result.append(newLine);
	    }
	    result.append("}");

	    return result.toString();
	  }

	public String getPrecio() {
		return precio;
	}

	public void setPrecio(String precio) {
		this.precio = precio;
	}

	public String getRating() {
		return rating;
	}

	public void setRating(String rating) {
		this.rating = rating;
	}

	public String getCantidad() {
		return cantidad;
	}

	public void setCantidad(String cantidad) {
		this.cantidad = cantidad;
	}
}
